﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Objects;
using BAL;

public partial class Admin_UCControls_UCDoiMatKhau : System.Web.UI.UserControl
{
    public static NguoiDung ItemNguoiDung;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ItemNguoiDung = new NguoiDung();
            ItemNguoiDung = (NguoiDung)Session["ItemDangNhap"];

            if (ItemNguoiDung != null)
            {
                txtTenTruyCap.Text = ItemNguoiDung.TenDangNhap.ToString();
            }
        }
    }

    protected void btnCapNhat_Click(object sender, EventArgs e)
    {
        int item;
        if (txtMatkhaumoi.Text != "" && txtMatkhaumoi.Text == txtNhaplaimoi.Text)
        {

            item = BALNguoiDung.Update_NguoiDung(Int32.Parse(ItemNguoiDung.Id.ToString()), ItemNguoiDung.TenNguoiDung.ToString(), ItemNguoiDung.TenDangNhap.ToString(), Common.ConvertMD5.EncryptionPassword(txtMatkhaumoi.Text), ItemNguoiDung.NgayTao, ItemNguoiDung.LanDangNhapCuoi,ItemNguoiDung.Quyen, 0);
            if (item > 0)
            {
                lblThongbao.Visible = true;
                lblThongbao.Text = "Đổi mật khẩu thành công";
            }
        }
        else
        {
            lblThongbao.Visible = true;
            lblMatKhau.Visible = true;
            lblNhapLai.Visible = true;
            lblThongbao.Text = "Nhập lại mật khẩu";
        }

    }
    protected void btnQuaylai_Click(object sender, EventArgs e)
    {
        Response.Redirect("../Admin/ChuDe.aspx");
    }
}
